<template>
  <div>
    <el-form ref="form" :model="user" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="user.name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="user.password"></el-input>
      </el-form-item>
      <el-form-item label="真实名字">
        <el-input v-model="user.trueName"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="user.email"></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="user.phone"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">添加</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
  
<script>
//引入user.js
import userApi from "@/api/rbac/user";

export default {
  name: "",
  data() {
    return {
      user: {},
    };
  },
  methods: {
    onSubmit() {
      userApi.add(this.user).then((result) => {
        if (result.ok) {
          this.$message({
            type: "success",
            message: result.msg,
          });
          //添加完了之后跳转到列表界面
          this.$router.push({path:'/rbac/user/list'})
        } else {
          this.$message({
            type: 'error',
            message: result.msg
          });
        }
      });
    },
  },
};
</script>
 
<style scoped>
</style>